<template>
  <div>
    <template>
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>促销方案通过表</h3>
      </div>
      <el-table
          :data="providerAudit"
          border
          style="width: 100%">
        <el-table-column
            prop="upod"
            label="促销编号">
        </el-table-column>
        <el-table-column
            prop="goodsid"
            label="商品编号">
        </el-table-column>
        <el-table-column
            prop="goodsname"
            label="商品名称">
        </el-table-column>
        <el-table-column
            prop="stocknum"
            label="数量">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="查看">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="button" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-dialog
          :visible.sync="dialogVisible"
          width="45%"
          :before-close="handleClose">
        <Ssalegoodsdecisionok ref="child1" @closeDialog="closeWiner" :usercodeTag="usercodeTag"></Ssalegoodsdecisionok>
      </el-dialog>

      <div class="block">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[6, 8, 10, 12]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
    </template>
  </div>
</template>

<script>

import Ssalegoodsdecisionok from "@/components/Ssalegoodsdecisionok";

export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Ssalegoods",
  components:{
    Ssalegoodsdecisionok
  },
  data(){
    return{
      pageNum: 1,
      pageSize: 6,
      total: '',
      providerAudit:[],
      messageget:'',
      dialogVisible:false,
      usercodeTag:''
    }
  },
  mounted() {
    this.init()
  },
  methods:{
    init(){
      let url = '/csc/salegoodsdecision/getAllSalegoodsdecision/'+ this.pageNum + "/" + this.pageSize+"/1"
      this.$axios.get(url).then(r=>{
        console.log(r.data)
        this.providerAudit = r.data.records
        this.total = r.data.total
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.init()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.init()
    },
    handleClick(row){
      console.log(row.salegoodsid+"-----------------")
      this.usercodeTag = row.salegoodsid
      this.dialogVisible = true
      this.$refs.child1.init(this.usercodeTag);
    },
    closeWiner(){
      this.init()
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped>

</style>